/*
 * This file is part of QuickCPP.
 * (c) Copyright 2011 Jie Wang(twj31470952@gmail.com)
 *
 * QuickCPP is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * QuickCPP is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with QuickCPP.  If not, see <http://www.gnu.org/licenses/>.
 */
 
//==============================================================================
//
// $Revision: 2 $
// $Date: 2011-02-22 06:59:58 +0000 (Tue, 22 Feb 2011) $
//
//==============================================================================

#include "Attribute.h"

QC_XML_NAMESPACE_BEGIN


Attribute::Attribute() :
	m_nIndex(-1)
{
}

Attribute::Attribute(const Attribute& rhs) :
	m_name(rhs.m_name),
	m_value(rhs.m_value),
	m_type(rhs.m_type),
	m_nIndex(rhs.m_nIndex)
{
}

Attribute::Attribute(const QName& name,
                     const String& type,
					 int nIndex) :
	m_name(name),
	m_type(type),
	m_nIndex(nIndex)
{
}

Attribute::Attribute(const QName& name,
                     const String& value,
                     const String&  type) :
	m_name(name),
	m_value(value),
	m_type(type),
	m_nIndex(-1)
{
}

//==============================================================================
// Attribute::isDefaulted
//
// Not a good name for a function I know, but this returns whether
// or not the attribute exists because it was specified in the XML
// stream or because it was generated by the DTD/Schema
//==============================================================================
bool Attribute::isDefaulted() const
{
	return (m_nIndex == -1);
}

//==============================================================================
// Attribute::getType
//
// Return the type of this attribute
//==============================================================================
const String& Attribute::getType() const
{
	return m_type;
}

//==============================================================================
// Attribute::getName
//
// Returns the attribute's name
//==============================================================================
const QName& Attribute::getName() const
{
	return m_name;
}

//==============================================================================
// Attribute::getValue
//
// Returns the attribute's value
//==============================================================================
const String& Attribute::getValue() const
{
	return m_value;
}

//==============================================================================
// Attribute::getIndex
//
// Returns the relative position that this attribute held within the
// attribute list within the source document
//==============================================================================
int Attribute::getIndex() const
{
	return m_nIndex;
}

//==============================================================================
// Attribute::setName
//
//==============================================================================
void Attribute::setName(const QName& name)
{
	m_name = name;
}

//==============================================================================
// Attribute::setValue
//
//==============================================================================
void Attribute::setValue(const String& value)
{
	m_value = value;
}

//==============================================================================
// Attribute::setType
//
//==============================================================================
void Attribute::setType(const String& type)
{
	m_type = type;
}

QC_XML_NAMESPACE_END

